using System.Drawing;
using FarPoint.Win.Spread;
using FarPoint.Win.Spread.CellType;

namespace Spread.Sparkline.Features
{
    public partial class AreaSparkline : Spread.Common.Features.Sample.BaseSampleControl
    {
        public AreaSparkline()
        {
            InitializeComponent();
            Name = "Area";

            InitSpreadsheet(fpSpread1.ActiveSheet);
        }

        #region Private methods
        private void InitSpreadsheet(SheetView sheetview)
        {
            var worksheet = sheetview.AsWorksheet();
            worksheet.Cells["A1:E1"].Merge();
            worksheet.Rows["1"].RowHeight = 32;

            worksheet.Cells["A1"].Text = "Revenue by State";
            worksheet.Cells["A1"].VerticalAlignment = GrapeCity.Spreadsheet.VerticalAlignment.Center;
            worksheet.Cells["A1"].Font.ApplyFont(new GrapeCity.Spreadsheet.Font() { Name = "Arial", Size = 17 });

            var table = worksheet.Tables.Add("A2:E6", GrapeCity.Spreadsheet.YesNoGuess.Guess, TableStyle.TableStyleLight1);
            table.ShowAutoFilter = false;

            worksheet.SetValue(1, 0, new object[,]
            {
                { "State", 2018, 2019, 2020, "Diagram" },
                { "Idaho", 10000, -9000, 15000, null },
                { "Montana", 1000, 9000, null, null },
                { "Oregon", 10000, 7000, 0, null },
                { "Washington", 1000, 10000, 5000, null },
                { "Utah", -5000, 5000, 12000, null }
            });

            worksheet.Cells["B3:D7"].CellType = new CurrencyCellType() { DecimalPlaces = 0 };
            worksheet.Cells["E3"].Formula = "AREASPARKLINE(B3:D3,,,0,10000,\"#82bc00\",\"#f7a711\")";
            worksheet.Cells["E4"].Formula = "AREASPARKLINE(B4:D4,,,0,10000,\"#82bc00\",\"#f7a711\")";
            worksheet.Cells["E5"].Formula = "AREASPARKLINE(B5:D5,,,0,10000,\"#82bc00\",\"#f7a711\")";
            worksheet.Cells["E6"].Formula = "AREASPARKLINE(B6:D6,,,0,10000,\"#82bc00\",\"#f7a711\")";
            worksheet.Cells["E7"].Formula = "AREASPARKLINE(B7:D7,,,0,10000,\"#82bc00\",\"#f7a711\")";

            worksheet.Rows["1"].RowHeight = 50;
            worksheet.Rows["2"].RowHeight = 25;
            worksheet.Rows["3:7"].RowHeight = 35;

            worksheet.Columns["A"].ColumnWidth = 100;
            worksheet.Columns["B:D"].ColumnWidth = 80;
            worksheet.Columns["E"].ColumnWidth = 200;
        }
        #endregion
    }
}


//
//AreaSparkline.Designer.cs
//


namespace Spread.Sparkline.Features
{
    partial class AreaSparkline
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AreaSparkline));
            this.fpSpread1 = new FarPoint.Win.Spread.FpSpread(FarPoint.Win.Spread.LegacyBehaviors.None, ((object)(resources.GetObject("pnlMain.Controls"))));
            this.fpSpread1_Sheet1 = this.fpSpread1.GetSheet(0);
            this.pnlMain.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).BeginInit();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Controls.Add(this.fpSpread1);
            // 
            // pnlControls
            // 
            this.pnlControls.Size = new System.Drawing.Size(210, 599);
            // 
            // fpSpread1
            // 
            this.fpSpread1.AccessibleDescription = "Book1, Sheet1, Row 0, Column 0";
            this.fpSpread1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fpSpread1.Font = new System.Drawing.Font("Calibri", 11F);
            this.fpSpread1.Location = new System.Drawing.Point(0, 0);
            this.fpSpread1.Name = "fpSpread1";
            this.fpSpread1.Size = new System.Drawing.Size(636, 599);
            this.fpSpread1.TabIndex = 0;
            // 
            // AreaSparkline
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "AreaSparkline";
            this.pnlMain.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private FarPoint.Win.Spread.FpSpread fpSpread1;
        private FarPoint.Win.Spread.SheetView fpSpread1_Sheet1;
    }
}
